<?php
class MailModel{
 	/**
 	 * 发送普通HTML邮件
 	 * Enter description here ...
 	 * @param string $address 收件人地址
 	 * @param string $title 邮件标题
 	 * @param string $body 邮件内容
 	 */
	public static function SendMail($address,$title,$body,$from=NULL){
		$Mail=new PHPMailer();
		$Mail->IsSMTP();
		$Mail->Host=SiteConfig::get('smtp_server'); // smtp.qq.com
		$Mail->SMTPAuth=(SiteConfig::get('smtp_auth')=='true');
		$Mail->CharSet=SiteConfig::get('smtp_charset');
		$Mail->Username=SiteConfig::get('smtp_user');
		$Mail->Password=SiteConfig::get('smtp_pass'); //这里输入密码
		$Mail->From=SiteConfig::get('smtp_from');
		$Mail->AddAddress($address); 
		$Mail->IsHTML(true);
		$Mail->Subject=$title;
		$Mail->Body=$body;
		return $Mail->Send();
	}
	/**
	 * 发送包含附件的邮件
	 * @param string $address 收件人地址
	 * @param string $title 邮件标题
	 * @param string $body 邮件内容
	 * @param string $Attachment 附件、多个附件用,好隔开
	 */
	public static function SendMailAttachment($address,$title,$body,$Attachment){
		$Mail=new PHPMailer();
		$Mail->IsSMTP();
        $Mail->Host=SiteConfig::get('smtp_server'); // smtp.qq.com
        $Mail->SMTPAuth=(SiteConfig::get('smtp_auth')=='true');
        $Mail->CharSet=SiteConfig::get('smtp_charset');
        $Mail->Username=SiteConfig::get('smtp_user');
        $Mail->Password=SiteConfig::get('smtp_pass'); //这里输入密码
        $Mail->From=SiteConfig::get('smtp_from');
		$Mail->AddAddress($address);
		if (stripos($Attachment, ',')){
			$file=explode(',', $Attachment);
			foreach ($file as $val){
				$Mail->AddAttachment($val);
			}
		}else{
			$Mail->AddAttachment($Attachment);
		}
		$Mail->IsHTML(true);
		$Mail->Subject=$title;
		$Mail->Body=$body;
		return $Mail->Send();
	}
}